
var map = new BMap.Map("allmap");

function getpos(e)
	{
		    
			var nowpoint = new BMap.Point(e.point.lng,e.point.lat);
            var geoc = new BMap.Geocoder();	
			geoc.getLocation(nowpoint, function(rs){
            var addComp = rs.addressComponents;	
            document.getElementById("gymnasium_location_province").value= addComp.province;
			 document.getElementById("gymnasium_location_city").value= addComp.city;
			 document.getElementById("gymnasium_location_district").value= addComp.district;
			 });
		document.getElementById("gymnasium_location_x").value=e.point.lng;
		document.getElementById("gymnasium_location_y").value=e.point.lat;
	}
$(function(){

    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 14);
    map.enableScrollWheelZoom();
    map.enableInertialDragging();
    map.enableContinuousZoom();
    var size = new BMap.Size(10, 20);
    map.addControl(new BMap.CityListControl({
    anchor: BMAP_ANCHOR_TOP_LEFT,
    offset: size,
    }));
	map.addEventListener("click", getpos);	
});
function search(e)
{
	map.centerAndZoom(new BMap.Point(map.getCenter().lng, map.getCenter().lat), 11);
	var local = new BMap.LocalSearch(map, {
		renderOptions:{map: map}
	});
	var keys=document.getElementById("location_search").value;
	local.search(keys);
}


